﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="Sequence", Namespace="http://kis.x-road.eu/", Target=typeof(Sequence))]
    public class SequenceSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected Sequence clazz;
        
        public SequenceSerializer(Sequence clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("SequenceElement");
            if (clazz.SequenceElement!=null) {
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SequenceElement))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SequenceElement");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="SequenceElement") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>Sequence>SequenceElement");
                }
                clazz.SequenceElement = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("SequenceElement")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>Sequence>SequenceElement", Reader.LocalName);
            }
        }
    }
}
